import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# 示例数据
# data = [191.27,
# 189.88,
# 188.5,
# 187.11,
# 185.72,
# 183.34,
# ]

data =[191.16,
183.6,
174.24,
166.05,
156.24,
146.25,
]
# 计算标准差
std_dev = np.std(data)
print(f"standed deviation: {std_dev}")

# 计算方差
variance = np.var(data)
print(f"variance: {variance}")

# 计算极差
range_val = np.max(data) - np.min(data)
print(f"range: {range_val}")


# 可视化
plt.figure(figsize=(12, 8))

# 1. 直方图
plt.subplot(2, 2, 1)
sns.histplot(data, kde=True, color='skyblue')
plt.title('histogram')
plt.xlabel('data')
plt.ylabel('frequency')

# 2. 箱线图
plt.subplot(2, 2, 2)
sns.boxplot(data, color='lightgreen')
plt.title('Boxplot')
plt.xlabel('data')

# 3. 散点图
plt.subplot(2, 2, 3)
sns.scatterplot(x=range(len(data)), y=data, color='salmon')
plt.title('Scatterplot')
plt.xlabel('id')
plt.ylabel('data')

# 4. 折线图
plt.subplot(2, 2, 4)
sns.lineplot(x=range(len(data)), y=data, color='purple')
plt.title('Lineplot')
plt.xlabel('id')
plt.ylabel('data')

plt.tight_layout()
plt.show()
